package IC.Types;

import IC.AST.ICClass;

public class ClassType extends Type {
	
	final String Name;
	final String BaseClassName;
	private final ICClass cAST;
	
	//C'tor
	public ClassType(String Name, String BaseClassName, ICClass cAST) {
		this.Name = Name;
		this.BaseClassName = BaseClassName;
		this.cAST = cAST;
	}
	
	@Override
	public boolean InstanceOf(Type type) {
	    if(super.InstanceOf(type)) return true;
		if (!type.isClass() || BaseClassName == null) return false;
		return TypeTable.classType(BaseClassName).InstanceOf(type);
	}

	@Override
	public boolean isSuitForArray() {
		return true;
	}

	@Override
	public boolean isArray() {
		return false;
	}

	@Override
	public boolean isClass() {
		return true;
	}

	@Override
	public boolean isMethod() {
		return false;
	}

	@Override
	public boolean isPrimitive() {
		return false;
	}
	
	public String getSuperClassName() {
		return this.BaseClassName;
	}
	
	public ICClass getICClass() {
		return getAst();
	}

	public ICClass getAst() {
		return cAST;
	}
		
	@Override
	public String toString() {
		return Name;
	}
	
}
